//
//  DesCell.m
//  Tour
//
//  Created by 才诗琦 on 16/3/9.
//  Copyright © 2016年 张中烨. All rights reserved.
//
#define HEIGHT layoutAttributes.frame.size.height
#define WIDTH layoutAttributes.frame.size.width
#import "DesCell.h"

@implementation DesCell
#pragma mark -  初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 照片
        self.photo = [[UIImageView alloc]init];
        [self.contentView addSubview:_photo];
        
        // 中文名称
        self.cnname = [[UILabel alloc]init];
        [self.contentView addSubview:_cnname];
        _cnname.font= [UIFont systemFontOfSize:20];
        _cnname.textColor = [UIColor whiteColor];
        
        // 英文名字
        self.enname = [[UILabel alloc]init];
        [self.contentView addSubview:_enname];
        _enname.font = [UIFont systemFontOfSize:15];
        _enname.textColor = [UIColor whiteColor];
       
        // 城市与 个数的背景图片
        self.backgound = [[UIImageView alloc]init];
        _backgound.backgroundColor = [UIColor grayColor];
        // 透明度
        _backgound.alpha = 0.8;
        [self.contentView addSubview:_backgound];
       
        // 个数
        self.count = [[UILabel alloc]init];
        [self.contentView addSubview:_count];
        _count.font = [UIFont systemFontOfSize:20];
        _count.textColor = [UIColor whiteColor];
        //        _count.backgroundColor= [UIColor redColor];
        _count.textAlignment = NSTextAlignmentCenter;
        
        // 城市
        self.label = [[UILabel alloc]init];
        [self.contentView addSubview:_label];
        _label.font = [UIFont systemFontOfSize:10];
        _label.textColor = [UIColor whiteColor];
        //        _label.backgroundColor = [UIColor yellowColor];
        _label.textAlignment = NSTextAlignmentCenter;
        
        
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    
    _photo.frame = CGRectMake(0, 0, WIDTH,HEIGHT);
    _cnname.frame = CGRectMake(5, HEIGHT - 60, WIDTH, 30);
    _enname.frame = CGRectMake(5, HEIGHT - 40, WIDTH, 30);
    _count.frame = CGRectMake(WIDTH - 43, 10, 37, 20);
    _label.frame = CGRectMake(WIDTH - 40, 30, 30, 20);
    _backgound.frame = CGRectMake(WIDTH - 43, 5, 35, _count.frame.size.height + _label.frame.size.height + 10);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
